####################################
# This is code to replicate the analyses and figures from the supplementary materials
# Produces information for Table 17
# (Un)Natural Disasters: Electoral Cycles in Disaster Relief
# Code developed by Alicia Cooperman and Andrea Junqueira
####################################
# Analysis conducted using
# R version 4.0.2 (2020-06-22) 
# on Platform: x86_64-apple-darwin17.0 (64-bit)
####################################

rm(list=ls(all=TRUE))
dev.off()
library(rdrobust) # Version 1.0.1
load("cooperman_2021_SI_RDD1.RData")
load("cooperman_2021_SI_RDD2.RData")

m1_gov <- rdrobust(y = mayoral_election_info_1$drought_gov, x = mayoral_election_info_1$running_var
                   , p = 1, c = 0		, level = 95, cluster = mayoral_election_info_1$year_mun, all = TRUE)
summary(m1_gov)

m1_gov_2years <- rdrobust(y = mayoral_election_info_1$drought_gov_2years, x = mayoral_election_info_1$running_var
                          , p = 1, c = 0, level = 95, cluster = mayoral_election_info_1$year_mun, all = TRUE)
summary(m1_gov_2years)

m2_mayor <- rdrobust(y = mayoral_election_info_2$drought_mayor, x = mayoral_election_info_2$running_var
                     , p = 1, c = 0, level = 95, cluster = mayoral_election_info_2$year_mun, all = TRUE)
summary(m2_mayor)

m2_mayor_2years <- rdrobust(y = mayoral_election_info_2$drought_mayor_2years, x = mayoral_election_info_2$running_var
                            , p = 1, c = 0, level = 95, cluster = mayoral_election_info_2$year_mun, all = TRUE)
summary(m2_mayor_2years)


